package eip.chapter4.guaranteed;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * Java representation of a grocery order
 * 
 * @author Tijs Rademakers
 */
public class GroceryOrder implements Serializable {
		
	private static final long serialVersionUID = -6843349119482589091L;
	private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
	private Integer orderID;
	private String hotelName;
	private Date orderDate;
	private ArrayList<Grocery> groceryList;
	
	//--------------------------------------------
	// Constructors
	//--------------------------------------------
	
	public GroceryOrder() {
	}
	
	public GroceryOrder(Integer orderID, String hotelName, 
			Date orderDate, ArrayList<Grocery> groceryList) {
		this.orderID = orderID;
		this.hotelName = hotelName;
		this.orderDate = orderDate;
		this.groceryList = groceryList;
	}
	
	//---------------------------------------------
	// Simple setters and getters
	//---------------------------------------------
	
	public ArrayList<Grocery> getGroceryList() {
		return groceryList;
	}

	public void setGroceryList(ArrayList<Grocery> groceryList) {
		this.groceryList = groceryList;
	}

	public String getHotelName() {
		return hotelName;
	}

	public void setHotelName(String hotelName) {
		this.hotelName = hotelName;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public Integer getOrderID() {
		return orderID;
	}

	public void setOrderID(Integer orderID) {
		this.orderID = orderID;
	}

	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "GroceryOrder ( "
	        + super.toString() + TAB
	        + "orderID = " + this.orderID + TAB
	        + "hotelName = " + this.hotelName + TAB
	        + "orderDate = " + dateFormat.format(this.orderDate) + TAB
	        + "groceryList = " + this.groceryList
	        + " )";
	    
	    return retValue;
	}	
}
